<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
        <script src="../vue.js"></script>
    </head>
    <body>
        <div id="app">
            {{b}}
            <!-- <com @child="handleChild"></com> -->
            <com :child.sync="b"></com>
        </div>
        <template id="com">
            <div>
                <button @click="handleClick">按钮</button>
            </div>
        </template>
        <script>
            let com = {
                template: '#com',
                data() {
                    return {
                        a: 100,
                    };
                },
                methods: {
                    handleClick() {
                        // this.$emit('child', this.a);
                        this.$emit('update:child', this.a);
                    },
                },
            };
            let vm = new Vue({
                el: '#app',
                data() {
                    return {
                        b: '',
                    };
                },
                methods: {
                    handleChild(val) {
                        this.b = val;
                        console.log(val);
                    },
                },
                components: {
                    com,
                },
            });
        </script>
    </body>
</html>
